home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / wrnsr094 / wrn.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1995-05-08  |  13.8 KB  |  407 lines

  1. VERSION 2.00
  2. Begin Form edit 
  3.    Caption         =   "News Reader"
  4.    ClientHeight    =   7350
  5.    ClientLeft      =   1815
  6.    ClientTop       =   1575
  7.    ClientWidth     =   10005
  8.    ControlBox      =   0   'False
  9.    Height          =   8040
  10.    Icon            =   WRN.FRX:0000
  11.    Left            =   1755
  12.    LinkMode        =   1  'Source
  13.    LinkTopic       =   "Form1"
  14.    ScaleHeight     =   7350
  15.    ScaleWidth      =   10005
  16.    Top             =   945
  17.    Width           =   10125
  18.    Begin TextBox Message_text 
  19.       BackColor       =   &H00FFFFFF&
  20.       FontBold        =   -1  'True
  21.       FontItalic      =   0   'False
  22.       FontName        =   "System"
  23.       FontSize        =   9.75
  24.       FontStrikethru  =   0   'False
  25.       FontUnderline   =   0   'False
  26.       Height          =   6855
  27.       Left            =   0
  28.       MultiLine       =   -1  'True
  29.       ScrollBars      =   2  'Vertical
  30.       TabIndex        =   0
  31.       Top             =   600
  32.       Width           =   9975
  33.    End
  34.    Begin PictureBox news_btn 
  35.       Height          =   495
  36.       Left            =   5760
  37.       Picture         =   WRN.FRX:0302
  38.       ScaleHeight     =   465
  39.       ScaleWidth      =   465
  40.       TabIndex        =   8
  41.       Top             =   0
  42.       Width           =   495
  43.    End
  44.    Begin PictureBox mail_btn 
  45.       Height          =   495
  46.       Left            =   5280
  47.       Picture         =   WRN.FRX:0604
  48.       ScaleHeight     =   465
  49.       ScaleWidth      =   465
  50.       TabIndex        =   7
  51.       Top             =   0
  52.       Width           =   495
  53.    End
  54.    Begin PictureBox uudecode_btn 
  55.       Height          =   495
  56.       Left            =   4320
  57.       Picture         =   WRN.FRX:0906
  58.       ScaleHeight     =   465
  59.       ScaleWidth      =   465
  60.       TabIndex        =   6
  61.       Top             =   0
  62.       Width           =   495
  63.    End
  64.    Begin PictureBox rot13_btn 
  65.       Height          =   495
  66.       Left            =   3840
  67.       Picture         =   WRN.FRX:0C08
  68.       ScaleHeight     =   465
  69.       ScaleWidth      =   465
  70.       TabIndex        =   5
  71.       Top             =   0
  72.       Width           =   495
  73.    End
  74.    Begin PictureBox cancel_btn 
  75.       Height          =   495
  76.       Left            =   2880
  77.       Picture         =   WRN.FRX:0F0A
  78.       ScaleHeight     =   465
  79.       ScaleWidth      =   465
  80.       TabIndex        =   4
  81.       Top             =   0
  82.       Width           =   495
  83.    End
  84.    Begin PictureBox save_btn 
  85.       Height          =   495
  86.       Left            =   2400
  87.       Picture         =   WRN.FRX:120C
  88.       ScaleHeight     =   465
  89.       ScaleWidth      =   465
  90.       TabIndex        =   3
  91.       Top             =   0
  92.       Width           =   495
  93.    End
  94.    Begin PictureBox load_btn 
  95.       Height          =   495
  96.       Left            =   1920
  97.       Picture         =   WRN.FRX:150E
  98.       ScaleHeight     =   465
  99.       ScaleWidth      =   465
  100.       TabIndex        =   2
  101.       Top             =   0
  102.       Width           =   495
  103.    End
  104.    Begin PictureBox new_btn 
  105.       Height          =   495
  106.       Left            =   1440
  107.       Picture         =   WRN.FRX:1810
  108.       ScaleHeight     =   465
  109.       ScaleWidth      =   465
  110.       TabIndex        =   1
  111.       Top             =   0
  112.       Width           =   495
  113.    End
  114.    Begin PictureBox next_btn 
  115.       Height          =   495
  116.       Left            =   0
  117.       Picture         =   WRN.FRX:1B12
  118.       ScaleHeight     =   465
  119.       ScaleWidth      =   465
  120.       TabIndex        =   9
  121.       Top             =   0
  122.       Width           =   495
  123.    End
  124.    Begin Menu clip_mnu 
  125.       Caption         =   "&Edit"
  126.       Begin Menu edit_cut_mnu 
  127.          Caption         =   "Cu&t"
  128.          Shortcut        =   ^T
  129.       End
  130.       Begin Menu edit_copy_mnu 
  131.          Caption         =   "&Copy"
  132.          Shortcut        =   ^C
  133.       End
  134.       Begin Menu edit_paste_mnu 
  135.          Caption         =   "&Paste"
  136.          Shortcut        =   ^P
  137.       End
  138.    End
  139.    Begin Menu info_mnu 
  140.       Caption         =   "&Info"
  141.    End
  142.    Begin Menu help_mnu 
  143.       Caption         =   "&Help"
  144.    End
  145. Sub cancel_btn_Click ()
  146.    edit.message_text.text = ""
  147.    If message.list1.listcount > 0 Then
  148.       message.enabled = True
  149.    End If
  150.    message.catchup_btn.enabled = True: message.catchup_btn.backcolor = white
  151.    new_btn.enabled = True: new_btn.backcolor = white
  152.    cancel_btn.enabled = False: cancel_btn.backcolor = grey
  153.    mail_btn.enabled = False: mail_btn.backcolor = grey
  154.    news_btn.enabled = False: news_btn.backcolor = grey
  155. End Sub
  156. Sub edit_copy_mnu_click ()
  157. ' Copy currently highlighted text to the clipboard
  158.     Dim CopyString As String
  159.     If message_text.SelLength > 0 Then
  160.     CopyString = message_text.SelText
  161.     Clipboard.SetText CopyString
  162.     End If
  163. End Sub
  164. Sub edit_cut_mnu_click ()
  165. ' Cut currently selected text to the clipboard
  166.     Dim CutString As String
  167.     Dim CursorPosition As Integer
  168.     If message_text.SelLength > 0 Then
  169.     CursorPosition = message_text.SelStart
  170.     CutString = message_text.SelText
  171.     Clipboard.SetText CutString
  172.     message_text.text = Left$(message_text.text, message_text.SelStart) + Right$(message_text.text, Len(message_text.text) - (message_text.SelStart + message_text.SelLength))
  173.     message_text.SelStart = CursorPosition
  174.     End If
  175. End Sub
  176.  Sub edit_paste_mnu_click ()
  177. ' Paste contents of clipboard into current card
  178.     Dim PasteText As String
  179.     Dim CursorPosition As Integer
  180.     CursorPosition = message_text.SelStart
  181.     PasteText = Left$(message_text.text, message_text.SelStart) + Clipboard.GetText()
  182.     PasteText = PasteText + Right$(message_text.text, Len(message_text.text) - (message_text.SelStart + message_text.SelLength))
  183.     message_text.text = PasteText
  184.     message_text.SelStart = CursorPosition + Len(Clipboard.GetText())
  185. End Sub
  186. Sub Form_DblClick ()
  187.    If Not mail_btn.enabled Then
  188.       message_text.SetFocus
  189.       If replying Then
  190.      msg_text$ = message_text.text
  191.      i& = InStr(msg_text$, Chr$(10))
  192.      While i& <> 0
  193.         msg_text$ = Left$(msg_text$, i&) + msg_quote$ + Mid$(msg_text$, i& + 1)
  194.         i& = i& + 3
  195.         i& = InStr(i&, msg_text$, Chr$(10))
  196.      Wend
  197.      message_text.text = msg_text$
  198.       Else
  199.      message_text.text = ""
  200.       End If
  201.       message.catchup_btn.enabled = False: message.catchup_btn.backcolor = grey
  202.       message.enabled = False
  203.       cancel_btn.enabled = True: cancel_btn.backcolor = white
  204.       mail_btn.enabled = True: mail_btn.backcolor = white
  205.       If Not reading_mail Then
  206.      news_btn.enabled = True: news_btn.backcolor = white
  207.       End If
  208.    End If
  209. End Sub
  210. Sub Form_Load ()
  211.    mail_btn.enabled = False: mail_btn.backcolor = grey
  212.    news_btn.enabled = False: news_btn.backcolor = grey
  213. End Sub
  214. Sub Form_Unload (Cancel As Integer)
  215.    Unload file_select
  216.    Unload aboutbox
  217. End Sub
  218. Sub get_block (ByVal file_no%, ByVal length%, dest$)
  219.    If Loc(file_no%) + length% > LOF(file_no%) Then
  220.       dest$ = dest$ + Input$(LOF(file_no%) - Loc(file_no%), file_no%)
  221.    Else
  222.       dest$ = dest$ + Input$(length%, file_no%)
  223.    End If
  224. End Sub
  225. Sub get_next_name (ByVal Path$, dest$)
  226.    i = 1
  227.    dest$ = Path$ + "." + Mid$(Str$(i), 2)
  228.    While Len(Dir$(dest$)) <> 0 And i < 1000
  229.      i = i + 1
  230.      dest$ = Path$ + "." + Mid$(Str$(i), 2)
  231.    Wend
  232. End Sub
  233. Sub Help_mnu_Click ()
  234.    res = winexec("WINHELP WRN.HLP", 1)
  235. End Sub
  236. Sub info_mnu_Click ()
  237.    edit.enabled = false
  238.    aboutbox.Show
  239. End Sub
  240. Sub load_btn_Click ()
  241.    filename$ = get_filename("c:\")
  242.    If Len(filename$) <> 0 Then
  243.       message_text.text = load_file(filename$)
  244.    End If
  245. End Sub
  246. Sub mail_btn_Click ()
  247.    dest$ = author$
  248.    sig% = 1
  249.    Call get_header(dest$, subject$, sig%, True)
  250.    seq_file = fopen(seq_path$, "r")
  251.    Input #seq_file, seq_num%
  252.    Close #seq_file
  253.    seq$ = Format$(seq_num%, "0000")
  254.       
  255.    out_filename$ = out_path$ + seq$
  256.    date_time$ = Format$(Now, "ddd, dd mmm yy hh:mm:ss ") + time_zone$
  257.    cur_time# = Now
  258.    out_file = fopen(out_filename$ + ".DAT", "w")
  259.    Print #out_file, "From " + user_id$ + "  " + date_time$ + Chr$(10);
  260.    Print #out_file, "Received: by " + site_name$ + " (1.65/waf+wrn)" + Chr$(10);
  261.    Print #out_file, Chr$(9) + "via UUCP; " + date_time$ + Chr$(10);
  262.    Print #out_file, Chr$(9) + "for " + dest$ + Chr$(10);
  263.    Print #out_file, "To: " + dest$ + Chr$(10);
  264.    Print #out_file, "Subject: " + subject$ + Chr$(10);
  265.    Print #out_file, "From: " + user_id$ + "@" + site_name$ + " (" + full_name$ + ")" + Chr$(10);
  266.    Print #out_file, "Message-ID: <" + Right$("0000" + Hex$(Int(cur_time#)), 4) + Right$("0000" + Hex$((cur_time# - Int(cur_time#)) * 65536), 4) + user_id$ + "@" + site_name$ + ">" + Chr$(10);
  267.    Print #out_file, "Date: " + date_time$ + Chr$(10);
  268.    If replying And (Len(msg_id$) <> 0) Then
  269.       Print #out_file, "In-Reply-To: " + msg_id$ + Chr$(10);
  270.    End If
  271.    Print #out_file, "Organization: " + organisation$ + Chr$(10);
  272.    Print #out_file, Chr$(10);
  273.    msg_text$ = message_text.text + signature(sig%)
  274.    pos = InStr(msg_text$, new_line)
  275.    While pos <> 0
  276.       Print #out_file, Left$(msg_text$, pos - 1) + Chr$(10);
  277.       msg_text$ = Mid$(msg_text$, pos + 2)
  278.       pos = InStr(msg_text$, new_line)
  279.    Wend
  280.    Close #out_file
  281.    out_file = fopen(out_filename$ + ".CMD", "w")
  282.    Print #out_file, "S " + seq$ + ".DAT D.whare" + seq$ + " " + user_id$ + " - " + seq$ + ".DAT 0666"
  283.    Print #out_file, "S " + seq$ + ".XQT X.whare" + seq$ + " " + user_id$ + " - " + seq$ + ".XQT 0666"
  284.    Close #out_file
  285.    out_file = fopen(out_filename$ + ".XQT", "w")
  286.    Print #out_file, "U " + user_id$ + " whare" + Chr$(10);
  287.    Print #out_file, "Z" + Chr$(10);
  288.    Print #out_file, "F D.whare" + seq$ + Chr$(10);
  289.    Print #out_file, "I D.whare" + seq$ + Chr$(10);
  290.    Print #out_file, "C rmail " + dest$ + Chr$(10);
  291.    Close #out_file
  292.    seq_file = fopen(seq_path$, "w")
  293.    Print #seq_file, seq_num% + 1
  294.    Close #seq_file
  295.    Call cancel_btn_Click
  296. End Sub
  297. Sub new_btn_Click ()
  298.    message_text.text = ""
  299.    subject$ = ""
  300.    author$ = ""
  301.    replying = False
  302.    new_btn.enabled = False: new_btn.backcolor = grey
  303.    reading_mail = False
  304.    message_text.SetFocus
  305. End Sub
  306. Sub news_btn_Click ()
  307.    sig% = 1
  308.    dest$ = message.combo1.list(message.combo1.listindex)
  309.    Call get_header(dest$, subject$, sig%, False)
  310.    seq = 0
  311.    out_filename$ = news_reply$ + "reply" + Mid$(Str$(seq), 2)
  312.    While Len(Dir$(out_filename$)) <> 0
  313.       seq = seq + 1
  314.       out_filename$ = news_reply$ + "reply" + Mid$(Str$(seq), 2)
  315.    Wend
  316.    date_time$ = Format$(Now, "ddd, dd mmm yy hh:mm:ss ") + time_zone$
  317.    cur_time# = Now
  318.    out_file = fopen(out_filename$, "w")
  319.    Print #out_file, "Path: " + site_name$ + "!" + user_id$
  320.    Print #out_file, "From: " + user_id$ + "@" + site_name$ + " (" + full_name$ + ")"
  321.    Print #out_file, "Newsgroups: " + dest$
  322.    Print #out_file, "Subject: " + subject$
  323.    Print #out_file, "Message-ID: <" + Right$("0000" + Hex$(Int(cur_time#)), 4) + Right$("0000" + Hex$((cur_time# - Int(cur_time#)) * 65536), 4) + user_id$ + "@" + site_name$ + ">"
  324.    Print #out_file, "Date: " + date_time$
  325.    If replying And (Len(msg_id$) <> 0) Then
  326.       Print #out_file, "References: " + msg_id$
  327.    End If
  328.    Print #out_file, "Organization: " + organisation$
  329.    Print #out_file, ""
  330.    Print #out_file, message_text.text
  331.    temp$ = signature(sig%)   ' Wierd bug to do with calling signature in print stmt
  332.    Print #out_file, temp$;
  333.    Close #out_file
  334.    out_file = fopen(out_news_list$, "a")
  335.    Call change_chars("\", "/", out_filename$)
  336.    Print #out_file, out_filename$
  337.    Close #out_file
  338.    reply_written = True
  339.    Call cancel_btn_Click
  340. End Sub
  341. Sub next_btn_Click ()
  342.    If message.list1.listindex < message.list1.listcount - 1 Then
  343.       message.list1.listindex = message.list1.listindex + 1
  344.    Else
  345.       If message.combo1.listindex < message.combo1.listcount - 1 Then
  346.      message.combo1.listindex = message.combo1.listindex + 1
  347.       Else
  348.      Beep
  349.       End If
  350.    End If
  351. End Sub
  352. Sub prune (text_line$, target$)
  353.    target_pos = InStr(text_line$, target$)
  354.    If target_pos <> 0 Then
  355.       text_line$ = Left$(text_line$, target_pos - 1) + Mid$(text_line$, InStr(target_pos, text_line$, Chr$(10)) + 1)
  356.    End If
  357. End Sub
  358. Sub rot13_btn_Click ()
  359.    msg_text$ = message_text.text
  360.    For i% = 1 To Len(msg_text$)
  361.       ch$ = Mid$(msg_text$, i%, 1)
  362.       If (ch$ >= "A" And ch$ <= "M") Or (ch$ >= "a" And ch$ <= "m") Then
  363.      Mid$(msg_text$, i%, 1) = Chr$(Asc(ch$) + 13)
  364.       Else
  365.      If (ch$ >= "N" And ch$ <= "Z") Or (ch$ >= "n" And ch$ <= "z") Then
  366.         Mid$(msg_text$, i%, 1) = Chr$(Asc(ch$) - 13)
  367.      End If
  368.       End If
  369.    Next i%
  370.    message_text.text = msg_text$
  371. End Sub
  372. Sub save_btn_Click ()
  373.    filename$ = get_filename(Left$(mail_file$, Len(mail_file$) - 8))
  374.    If Len(filename$) <> 0 Then
  375.       save_file = fopen(filename$, "a")
  376.       If reading_mail Then
  377.      msg_text$ = get_mail(message.list1.listindex)
  378.      Print #save_file, msg_text$
  379.       Else
  380.      in_file = fopen(msg_filename, "r")
  381.      While Not EOF(in_file)
  382.         Input #in_file, msg_line$
  383.         Print #save_file, msg_line$
  384.      Wend
  385.      Close #in_file
  386.       End If
  387.       Close #save_file
  388.    End If
  389. End Sub
  390. Function signature (ByVal sig_flag%) As String
  391.    If registered Then
  392.       If sig_flag% = 1 Then
  393.      signature = new_line + "--" + new_line + load_file(sign_filename$) + new_line
  394.       Else
  395.      signature = ""
  396.       End If
  397.    Else
  398.       signature = new_line + "--" + new_line + "Using an unregistered copy of WRN v0.94" + new_line
  399.    End If
  400. End Function
  401. Sub uudecode_btn_Click ()
  402.    Call make_dir(message.combo1.list(message.combo1.listindex), Dirname$)
  403.    file$ = message.list1.list(message.list1.listindex)
  404.    file$ = Left$(file$, InStr(file$, ":") - 1)
  405.    res = winexec(uudecoder$ + " " + Dirname$ + file$, 1)
  406. End Sub
  407.